<!DOCTYPE html>
<html>
 <head> 
  <meta charset="UTF-8" /> 
  <title>购物车</title> 
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> 
  <meta name="apple-mobile-web-app-capable" content="yes" /> 
  <meta name="apple-mobile-web-app-status-bar-style" content="black" /> 
  <meta name="format-detection" content="telephone=no" /> 
  <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/semantic.css"/>
  <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/main.css">
  <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/common.css">
  <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/light-theme.css">
  <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/m2015.css" />

  <script src="__PUBLIC__/Js/m_Common.js"></script>
  <script src="__PUBLIC__/Js/CartMgr.js"></script>
  <script src="__PUBLIC__/Js/TouchSlide.1.0.js"></script>

     <script language="JavaScript" type="text/javascript">
         function changeState(isChecked)
         {
             var chk_list=document.getElementsByTagName("input");
             for(var i=0;i<chk_list.length;i++)
             {
                 if(chk_list[i].type=="checkbox")
                 {
                     chk_list[i].checked=isChecked;
                 }
             }
         }
     </script>

 </head>


 <body style="padding-bottom: 90px;"> 
 
  <div class="wrapper cart_box"> 
  <form name="form3" method="post" action="__APP__/Gouwu/delBuyList_all">
   <div class="vlist" style="padding: 0;"> 
    <div class="all-checked"> 
     <label> <input type="checkbox" onclick="changeState(this.checked)" />全选</label>
     <label>
         <input type="submit" name="action" value="删除" onClick="{if(confirm('确定删除选中购物车订单?')){return true;}return false;}">
         <input type="submit" name="action" value="确认订单">
         <input type="submit" name="action" value="去结算">
     </label>

     <a href="__APP__/Gouwu/reset" class="right" onClick="{if(confirm('确定清空全部购物车订单?')){return true;}return false;}"><i class="trash icon"></i> 清空购物车</a>
    </div> 
    <ul> 
     <volist name="arr" id="vo" >
                 <li class="cart_one"> 
                   <div class="check-box"> 
                    <input type="checkbox" name="oid[]" value="{$info[$vo['id']]['order_id']}" id="oid[]" >
                   </div> 
                   
                   <label for="basket_3263300"> <img class="list_img" src="{$info[$vo['id']]['img']}">
                     <div class="list_info"> 
                         <div class="tit c666">
                          产品名称： {$info[$vo['id']]['name']}
                         </div> 
                         <div class="price red2" style="padding-bottom: 35px;">
                           产品单价：￥ 
                          <span> {$info[$vo['id']]['money']}</span>
                         </div>
                         <div class="cls"></div> 
                     </div> 
                   </label> 
                   <p class="qingdan_shul cart_num">购买数量：<span>{$info[$vo['id']]['num']}</span></p>
                   
                   <a href="__APP__/Gouwu/delBuyList/id/{$info[$vo['id']]['order_id']}" onClick="{if(confirm('确定删除该购物车订单?')){return true;}return false;}"><span class=" btn box-remove btn-mini btn-link cart_del note__close"><i class="trash icon"></i></span></a>
                   
               </li> 
</volist>
    </ul> 
   <div style="height:150px;background-color:#fff;"></div> 
   </div> 
 
   <div class="cart-status"> 
    <script type="text/html" id="cartTotalTmpl">
                {{if cartCount!=0}}
            <div class="cart_btn" style="margin-bottom: 50px;">
                <p style="margin-top: 10px;">您选择了<span>{{checkedCount}}</span>件商品，总计：<b class="red1">￥{{cartPrice}}</b></p>
                  <input name="shu" type="hidden" class="ipt"  id="shu" value="{{checkedCount}}"/>
                  <input name="money" type="hidden" class="ipt"  id="money" value="{{cartPrice}}"/>

                <a href="__APP__/Index/index" class="ui large green submit btn" style="background: #21BA45;">继续购物</a>
                 <input type="submit" name="action" value="去结算" class="ui large large orange submit btn" onclick="{if(confirm('确定要去结算吗?')){return true;}return false;}" style="width: 140px;height: 40px;font-size: 18px;"> 
            </div>
                {{/if}}
            {{if cartCount==0}}
            <div class="cart-empty">
                <p>购物车里什么都没有，快去买点什么吧~</p>
                <a href="__APP__/Index/index">去逛逛</a>
            </div>
                {{/if}}
            </script> 
   </div> 
   </form>
  </div> 
  <!--配件颜色选择--> 
  <div class="color_pj" id="color_pj"> 
   <div class="color_bd"> 
    <ul id="m_bigpics"></ul> 
   </div> 
   <div class="color_hd"> 
    <ul id="m_pics"></ul> 
   </div> 
   <div class="pop_foot" style="height: 50px;"> 
    <p><a href="javascript:buy_peijian()" class="buy_server" style="background: #f60; color: #fff;">加入购物车</a><a href="javascript:over_color()" class="over" style="background: #f1f1f1;">返回购物车</a></p> 
   </div> 
  </div> 
  <script type="text/javascript">
        $(function () {
            $(".cart_one").each(function (index, item) {
                var product = $(item);
                BindEvent(product);
            });
            $(".cart_box .lh").each(function () {
                if ($.trim($(this).text()).length > 0) { $("#lhCartTip").show(); return false; }
            });

        });
        $(".all-checked input").change(function () {
            if ($(this).prop("checked") == true) {
                $(".vlist ul li input[type='checkbox'],.all-checked input").prop("checked", true);
            } else {
                $(".vlist ul li input[type='checkbox'],.all-checked input").prop("checked", false);
            }
            CalcAmount();
        });
        $("input[name='id[]']").change(function () {
            if ($(this).prop("checked") == false) {
                $(".all-checked input").prop("checked", false);
            }
            CalcAmount();
        });
        function buy() {
            var basketids = [];
            $("input[name='id[]']").each(function () {
                if ($(this).prop("checked") == true) {
                    basketids.push($(this).val())
                }
            });
            if (basketids.length ==0) {
                layer.open({ content: "请至少勾选一个商品购买！", shadeClose: false, btn: ['好的'] });
                return;
            }
            layer.open({ type: 2, content: "加载中...", shadeClose: false });
            $.post("?", { basketids: basketids.join(',') }, function (res) {
                layer.closeAll();
                if (res.status == 1) {
                    window.location.href = "cartStep.aspx";
                } else {
                    layer.open({ content: "报错啦！", shadeClose: false, btn: ['好的'] });
                }
            }, "json");
        }
    </script> 
  <script type="text/javascript">

         window["_BFD"] = window["_BFD"] || {};

         _BFD.BFD_INFO = {

             "user_id": Cookie.Get("ch999MemberID"), //网站当前用户id，如果未登录就为0或空字符串


             "page_type": "shopcart" //当前页面全称，请勿修改

         };
    </script> 
  <!--新增js--> 
  <script>

        var the;
        var BuyService=null;
        function server(type, self, basketid, serviceid) {
            BuyService = { baskid: basketid, servicesid: serviceid };
            the = self;
            var serviceprice=$(the).attr('price');
            if ($(self).hasClass("no_sel")) {
                switch (type) {
                    case 0:
                        var html = '';
                        break;
                    case 1:
                        var html = '';
                        break;
                }
                layer.open({
                    type: 1,
                    content: html,
                    style: 'height:100%; width:100%; border:none;',
                    success: function () {
                        var height = $(window).height() - 170;
                        $(".view").css("height", height);
                    }
                });
            } else {
                switch (type) {
                    case 0:
                        var test = '',
                            test1 = '';
                        break;
                    case 1:
                        var test = '',
                            test1 = '';
                        break;
                }
                layer.open({
                    content: test + '您确定放弃此次' + test1 + '机会么？',
                    btn: ['确认', '取消'],
                    shadeClose: false,
                    yes: function ()
                    {
                        chooseServicesid(0,function () {
                            $(self).removeClass("sel").addClass("no_sel");
                            layer.open({ content: '已为您取消该服务', time: 1 });
                            $(self).find("em").text("购买服务");
                        }, function () {
                            layer.open({ content: '取消该服务失败', time: 2 });
                        });

                    }, no: function () {
                        layer.close();
                    }
                });
            }
        };

        function chooseServicesid(actid,okcall, errcall)
        {
            var ppids = '';  $('.sel' + BuyService.baskid).each(function(i,el){
                if ($(el).hasClass('sel')) ppids += $(el).attr('serviceid') + ',';
            });
            if (actid == 1)
                ppids += BuyService.servicesid + ',';
            else
                ppids = ppids.replace(BuyService.servicesid + ',', '');
            
            var data = { baskid: BuyService.baskid, servicesid: ppids };
            $.post('cartStep.aspx?act=chooseServicesid', data, function (res) {
                layer.closeAll();
                if (res == 1) {
                    if(okcall) okcall();
                    window.location.reload();
                } else {
                    if(errcall) okcall();
                    layer.open({ content: '服务购买失败', time: 2 });
                }
            }, 'text');
        }

        function ido(btn) {
            var check1 = $("#check1").is(":checked");
            var check2 = $("#check2").is(":checked");
            if (check1 || check2)
            {
                chooseServicesid(1,function () {
                    var len = $(the).parent().siblings("label").find(".cart_num").children("span").text();
                    $(the).removeClass("no_sel").addClass("sel");
                    $(the).find("em").text("x" + len);
                }, function () {
                    layer.open({ content: '服务购买失败', time: 2 });
                });
            } else {
                layer.open({ content: '必须接受服务条款才可以购买', time: 2 });
            }
        }

        /*关闭弹出层*/
        function over() {
            BuyService = null;
            layer.closeAll();
        }



        /*购买配件*/
        function ibuypj(ppriceid) {
            layer.open({type:2,content:"加载中...",shadeClose:false});
            $.post("/ajax/initCart.aspx",{type:'m', ppid:ppriceid},function(res){
                if(res.stats==1){
                    window.location.reload();
                }else{
                    layer.closeAll();
                }
            },"json");
        }        

        var thepj;
        function selcolor(self, productid, ppid) {
            thepj = $(self);
            if (thepj.hasClass("color_sel")) {
                var prolsit=CartPJJson[productid];
                if(prolsit!=null){
                    var bigpics='',smalls='';
                    for(var i=0;i<prolsit.length;i++){
                        var m=prolsit[i];
                        bigpics+='<li><h3><span>'+m.name+'</span><em>'+m.price+'元</em></h3><img src="http://img2.ch999img.com/pic/product/160x160/'+m.img+'"/></li>';
                        smalls+=' <li data-name="'+m.name+'" data-ppid="'+m.ppid+'" data-money="'+m.price+'"><img src="http://img2.ch999img.com/pic/product/70x70/'+m.img+'"/><p style="font-size:14px; text-align:center; margin-top:5px;">'+m.color+'</p></li>';
                    }
                    $('#m_bigpics').html(bigpics);
                    $('#m_pics').html(smalls);
                    $("#color_pj").show();
                    var width = $(window).width(),
                        len = $(".color_hd li").length;
                    $(".color_bd li").css("width", width);
                    $(".color_hd").css("width", width - 10);
                    $(".color_hd ul").css("width", 78 * len);
                    TouchSlide({ slideCell: "#color_pj", titCell: ".color_hd li", mainCell: ".color_bd ul", titOnClassName: "color_active", effect: "left", delayTime: 500, autoPage: false });
                }
            }else{
                ibuypj(ppid);
            }
        };

        //购买配件 -- 加入购物车
        function buy_peijian() {
            var name = $(".color_active").attr("data-name");
            var money = $(".color_active").attr("data-money");
            var ppid = $(".color_active").attr("data-ppid");
            ibuypj(ppid);
        }
        //返回购物车
        function over_color(){
            $("#color_pj").hide();
            thepj.find("input[type=checkbox]").prop("checked",false);
        }

        function removeProduct(basketID, callback) {
            if (!confirm("确定要移除此商品吗？")) return;
            layer.open({ type: 2, shadeClose: false });
            sendPostRequest("/ajax/cartHandler.aspx?act=delCar", { id: basketID }, function () {
                layer.closeAll();
                window.location.reload();
                $(".cart_one").has("input[value='" + basketID + "']").remove();
                CalcAmount();
            }, $.noop);
        }

        function CalcAmount() {
            var totalAmount = 0;
            var productCount = 0;
            var hasCount = 0;
            $(".cart_one").each(function (index, item) {
                hasCount++;
                var curProBox = $(this);
                if (curProBox.find("input[name = 'id[]']").prop("checked") == true) {
                    var curProPrice = curProBox.find("input[type='hidden'][name='price']");

                    var inputer = curProBox.find(".cart_plus input");
                    var unitPrice = parseFloat(curProPrice.val());

                    if (inputer.size() > 0) {
                        var productPrice = unitPrice * parseInt(inputer.val());
                        productCount += parseInt(inputer.val());
                        totalAmount += productPrice;
                        curProBox.find(".price span").text(productPrice.toFixed(2));
                    } else {
                        totalAmount += unitPrice;
                        productCount++;
                    }
                    $(".cart_other input[name='price']", item).each(function () {
                        totalAmount += parseInt($(this).val());
                    });
                }
            });
            var data = { cartCount: hasCount, checkedCount: productCount, cartPrice: totalAmount.toFixed(2) };
            $('.baozhang .sel').each(function(i,el){
                data.cartPrice= parseFloat(data.cartPrice) + parseFloat($(el).attr('price'));
            });
            $(".cart-status").html(template("cartTotalTmpl",data));
        }

    </script>  

    <script type="text/javascript">
$(".note__close").click(function(){
  $(this).parent().fadeOut(500, function(){
    $(this).remove();
  });
});
</script>
  <div class="main-bottom">
      <div class="col-xs-3">
          <a href="__APP__/Gouwu/Buycp2/" class="">
              <i class="home icon"></i>
              <div>首页</div>
          </a>
      </div>
      <!--<div class="col-xs-3">-->
      <!--<a href="__APP__/Gouwu/wsmall" class="">-->
      <!--<i class="star icon"></i>-->
      <!--<div>微店</div>-->
      <!--</a>-->
      <!--</div>-->

      <div class="col-xs-3">
          <a href="__APP__/Gouwu/gpai" class="">
              <i class="star icon"></i>
              <div>会员管理</div>
          </a>
      </div>
      <div class="col-xs-3">
          <a href="__APP__/Index/index/" class="">
              <i class="user icon"></i>
              <div>个人中心</div>
          </a>
      </div>
      <div class="col-xs-3">
          <a href="__APP__/Gouwu/shopCar/" class="">
              <i class="shop icon"></i>
              <div>购物车</div>
          </a>
      </div>
  </div>
 </body>
</html>